<template>
  <div class="custom-header">
    <el-tooltip
      class="item"
      effect="dark"
      :content="content"
      placement="top"
      :disabled="disabled"
    >
      <p @mouseenter="mouseenter" @mouseleave="mouseleave">
        {{ content }}
      </p>
    </el-tooltip>
  </div>
</template>

<script>
export default {
  props: {
    content: {
      type: String,
      default: '内容'
    }
  },
  data() {
    return {
      disabled: true
    }
  },
  methods: {
    mouseenter(e) {
      console.log(e.target.clientWidth, e.target.scrollWidth)
      if (e.target.scrollWidth <= e.target.clientWidth) {
        this.disabled = true
      } else {
        this.disabled = false
      }
      console.log(this.disabled)
    },
    mouseleave() {}
  }
}
</script>
<style lang="less">
p {
  margin: 0;
}
.custom-header {
  p {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin: 0;
  }
}
</style>
